from django.db import models

# Create your models here.

class Book(models.Model):
    id=models.AutoField(primary_key=True)
    title=models.CharField(max_length=32)
    publishDate=models.DateField()
    price=models.DecimalField(max_digits=5,decimal_places=2)

    def __str__(self):

        return self.name


class Publish(models.Model):
    id=models.AutoField(primary_key=True)
    name=models.CharField(max_length=32,verbose_name='出版商名称')
    city=models.CharField(max_length=20,verbose_name='城市')

    def __str__(self):
        return self.name

class Author(models.Model):
    id=models.AutoField(primary_key=True)
    name = models.CharField(max_length=32,verbose_name='作者名称')


#
# class Book(models.Model):
#     id=models.AutoField(primary_key=True)
#     title=models.CharField(max_length=32)
#     publishDate=models.DateField()
#     price=models.DecimalField(max_digits=5,decimal_places=2)
#     publish=models.ForeignKey('Publish',verbose_name='所属出版商',on_delete=models.CASCADE)
#     author=models.ManyToManyField('Author',verbose_name='所属作者',on_delete=models.CASCADE)
#
#     def __str__(self):
#
#         return self.name
#
#
# class Publish(models.Model):
#     id=models.AutoField(primary_key=True)
#     name=models.CharField(max_length=32,verbose_name='出版商名称')
#     city=models.CharField(max_length=20,verbose_name='城市')
#
#     def __str__(self):
#         return self.name
#
# class Author(models.Model):
#     id=models.AutoField(primary_key=True)
#     name = models.CharField(max_length=32,verbose_name='作者名称')
#     age = models.ImageField(verbose_name='年龄')
#
#     def __str__(self):
#         return self.name


# python3 manage.py makemigrations   创建脚本
# python3 manage.py migrate   迁移